﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>代码生成器 - 代码浏览</title>
    <link href="/Themes/Scripts/highlight/styles/default.css" rel="stylesheet" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <!--代码高亮 start-->
    <script src="/Themes/Scripts/highlight/highlight.pack.js"></script>
    <script src="/Themes/Scripts/common.js" type="text/javascript"></script>
    <style type="text/css">
        #t1, #t2 {
            width: 100%;
        }

        tr {
            vertical-align: top;
        }
    </style>
    <script type="text/javascript">
        hljs.initHighlightingOnLoad();
        String.prototype.escape = function () {
            return this.replace(/&/gm, '&amp;').replace(/</gm, '&lt;').replace(/>/gm, '&gt;');
        }
        $(function () {
            var url = "/Ajax/Bulid.ashx";
            var para = "action=BulidCode";
            para += "&db=" + escape(GetQuery('db'));//数据库
            para += "&table=" + escape(GetQuery('table'));//表名
            para += "&tableRemark=" + GetQuery('tableRemark');//表说明
            para += "&tableId=" + escape(GetQuery('tableId'));
            para += "&templete=" + escape(GetQuery('templete'));//模板
            para += "&type=" + GetQuery('type');//类型 bll ibll model form list
            para += "&columnnum=" + GetQuery('columnnum');//每行x列
            para += "&ispage=" + GetQuery('ispage');//是否分页

            //alert(unescape(GetQuery('tableRemark')));
            //alert(decodeURI(GetQuery('tableRemark')));
            if (top.div_Form != null)//Form.aspx跳转
                para += "&columns=" + top.div_Form.$("#hi_column").val();

            Ajax(url, para, function (data) {
                if (data == null || data == "0") {
                    ShowTipsMsg("<span style='color:red'>代码生成失败，请稍后重试！</span>", 4000, 5);
                } else if (data.length > 0) {
                    var t1 = document.getElementById("t1");
                    t1.value = data;
                    DoIt();
                }
            });

        });
        function DoIt() {
            var viewDiv = document.getElementById("highlight-view");
            var t1 = document.getElementById("t1");
            var t2 = document.getElementById("t2");
            var selector = document.getElementById("langSelector");
            var selectedLang = selector.options[selector.selectedIndex].value.toLowerCase();
            if (selectedLang) {
                viewDiv.innerHTML = '<pre><code class="' + selectedLang + '">' + t1.value.escape() + "</code></pre>";
            } else { // try auto
                viewDiv.innerHTML = '<pre><code>' + t1.value.escape() + "</code></pre>";
            }
            hljs.highlightBlock(viewDiv.firstChild.firstChild);
            t2.value = viewDiv.innerHTML;
            $("#highlight-view").height($(window).height() - 360);
        }

        function CopyToBuffer(textToCopy) {
            if (window.clipboardData) { // IE
                window.clipboardData.setData("Text", textToCopy);
            } else if (window.netscape) { // FF
                netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
                var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
                clipboardHelper.copyString(textToCopy);
            }
        }
    </script>
</head>
<body>
    <script type="text/javascript">
        var langSelectorHtml = '<label>语言 <select id="langSelector">';
        langSelectorHtml += '<option value="">Auto</option>';
        for (var i in hljs.LANGUAGES) {
            if (hljs.LANGUAGES.hasOwnProperty(i))
                langSelectorHtml += '<option value=\"' + i + '\">' + i.charAt(0).toUpperCase() + i.substr(1) + '</option>';
        }
        langSelectorHtml += '</select></label>';
        document.write(langSelectorHtml);
    </script>
    <table width="100%">
        <tr>
            <td><textarea rows="10" cols="50" id="t1"></textarea></td>
            <td><textarea rows="10" cols="30" id="t2"></textarea></td>
        </tr>
        <tr>
            <td>Write a code snippet</td>
            <td>Get HTML to paste anywhere (for actual styles and colors see sample.css)</td>
        </tr>
    </table>
    <table width="98%">
        <tr>
            <td><input type="button" value="转换" onclick="DoIt()" /></td>
            <td align="right"><input type="button" value="复制" onclick="CopyToBuffer(document.getElementById('t2').value);" /></td>
        </tr>
    </table>
    <div id="highlight-view" style="overflow-x: auto; overflow-y: scroll;"></div>
</body>
</html>
